package com.yty.system.oauth.entity.vo;


public enum ReturnCode {

    CLIENT_AUTHENTICATION_FAILED(1001,"客户端认证失败"),
    USERNAME_OR_PASSWORD_ERROR(1002,"用户名或密码错误"),
    UNSUPPORTED_GRANT_TYPE(1003, "不支持的认证模式"),
    TOKEN_FAIL(201, "认证失败，请传递token");

    private int code;
    private String desc;

    ReturnCode(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 自己定义一个静态方法,通过code返回枚举常量对象
     * @param code
     * @return
     */
    public static ReturnCode getValue(int code){
        for (ReturnCode  r: values()) {
            if(r.getCode() == code){
                return r;
            }
        }
        return null;

    }

    public int getCode() {
        return code;
    }
    public void setCode(int code) {
        this.code = code;
    }
    public String getDesc() {
        return desc;
    }
    public void setDesc(String desc) {
        this.desc = desc;
    }
}
